import random
import string
import time

all_chs = string.digits + string.ascii_letters + string.punctuation     #包含数字、大小写字母和标点符号
result = ''
n = eval(input("您希望生成的密码有几位？\n"))

for i in range(n):
    ch = random.choice(all_chs)                #从all_chs中选择一个字符
    result += ch
print(result)

time.sleep(100)